#! /usr/bin/env python
#$Revision: 1.3 $

BASE="/usr/local"
GAME=BASE+"/games/leiserieselt"
CODE=GAME+"/code"
DATA=GAME+"/data"
BIN =BASE+"/bin"

import os, string, sys

def main(args):
    print "Installing into ", GAME
    
    try:
        os.makedirs(CODE)
        os.makedirs(DATA)
        os.makedirs(BIN)
    except:
        pass
    
    try:
        os.stat(CODE)
        os.stat(DATA)
        os.stat(BIN)
    except:
        print "Error while creating directories..."
        return
    
    os.system("cp -a ./Data/* "+DATA)
    os.system("cp -a ./Src/* "+CODE)
    os.unlink(CODE+"/leiserieselt.py")

    f=file("./Src/leiserieselt.py", "r")
    o=file(CODE+"/leiserieselt.py", "w")
    for l in f:
        l = l[:-1]
        if string.find(l, "CODEDIR") == 0:
            l =  'CODEDIR="%s"' % CODE
        elif string.find(l, "DATADIR") == 0:
            l =  'DATADIR="%s"' % DATA
        print >>o, l
    print CODE+"/leiserieselt.py", BIN+'/'
    os.symlink(CODE+"/leiserieselt.py", BIN+'/leiserieselt.py')
    os.system("chmod a+x %s" % CODE+"/leiserieselt.py")

if __name__ == "__main__": main(sys.argv)
